package com.itheima.health.controller.admin;

import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import com.itheima.health.common.MessageConst;
import com.itheima.health.dto.MemberVO;
import com.itheima.health.dto.SetmealVO;
import com.itheima.health.pojo.Business;
import com.itheima.health.result.Result;
import com.itheima.health.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;


@RestController
@RequestMapping("/report")
@Slf4j
public class ReportController {


    @Autowired
    private ReportService reportService;

    @GetMapping("/getMemberReport")
    public Result getMemberReport(){
        MemberVO memberVO =reportService.getMemberReport();


        return new Result(true, MessageConst.GET_MEMBER_NUMBER_REPORT_SUCCESS,memberVO);

    }

    @GetMapping("/getSetmealReport")
    public Result getSetmealReport(){
        SetmealVO setmealVO=reportService.getSetmealReport();

        return new Result(true,MessageConst.GET_SETMEAL_COUNT_REPORT_SUCCESS,setmealVO);
    }
    @GetMapping("/getBusinessReportData")
    public Result getBusinessReportData(){
        Business business=reportService.getBusinessReportData();

        return new Result(true,MessageConst.ACTION_SUCCESS,business);
    }
    @RequestMapping("/exportBusinessReport")
    public Result exportBusinessReport(HttpServletResponse response){
        reportService.exportBusinessReport(response);
        return new Result(true,MessageConst.UPLOAD_SUCCESS);
    }
}
